package com.masterclient.app.modules.category.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.masterclient.app.R;
import com.masterclient.app.modules.category.beans.CategoryDetailBean;

import java.util.List;

/**
 * 作者：sean
 * 创建时间：2017/7/7 17:30
 * 功能说明：
 */

public class BrandGridAdapter extends BaseAdapter{

    private Context context;
    List<CategoryDetailBean.ShTopArrBean> list;
    public BrandGridAdapter(Context context, List<CategoryDetailBean.ShTopArrBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list == null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.tv_city,null);
        ((TextView)convertView).setText(list.get(position).getSh_name());
        if(list.get(position).isSelect()){
            ((TextView)convertView).setTextColor(context.getResources().getColor(R.color.white));
            convertView.setBackgroundResource(R.drawable.shape_round_f23051_fff2f5);
        }else {
            ((TextView)convertView).setTextColor(context.getResources().getColor(R.color.text_666));
            convertView.setBackgroundResource(R.drawable.shape_round_999faa);
        }
        return convertView;
    }
}
